/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Index;
import org.xtext.example.cr.cR.SimpleVariable;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Index</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.IndexImpl#getParam1 <em>Param1</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.IndexImpl#getVar1 <em>Var1</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.IndexImpl#getParam2 <em>Param2</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.IndexImpl#getVar2 <em>Var2</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class IndexImpl extends MinimalEObjectImpl.Container implements Index
{
  /**
   * The default value of the '{@link #getParam1() <em>Param1</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParam1()
   * @generated
   * @ordered
   */
  protected static final int PARAM1_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getParam1() <em>Param1</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParam1()
   * @generated
   * @ordered
   */
  protected int param1 = PARAM1_EDEFAULT;

  /**
   * The cached value of the '{@link #getVar1() <em>Var1</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVar1()
   * @generated
   * @ordered
   */
  protected SimpleVariable var1;

  /**
   * The default value of the '{@link #getParam2() <em>Param2</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParam2()
   * @generated
   * @ordered
   */
  protected static final int PARAM2_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getParam2() <em>Param2</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParam2()
   * @generated
   * @ordered
   */
  protected int param2 = PARAM2_EDEFAULT;

  /**
   * The cached value of the '{@link #getVar2() <em>Var2</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVar2()
   * @generated
   * @ordered
   */
  protected SimpleVariable var2;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected IndexImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.INDEX;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getParam1()
  {
    return param1;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParam1(int newParam1)
  {
    int oldParam1 = param1;
    param1 = newParam1;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.INDEX__PARAM1, oldParam1, param1));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SimpleVariable getVar1()
  {
    if (var1 != null && var1.eIsProxy())
    {
      InternalEObject oldVar1 = (InternalEObject)var1;
      var1 = (SimpleVariable)eResolveProxy(oldVar1);
      if (var1 != oldVar1)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, CRPackage.INDEX__VAR1, oldVar1, var1));
      }
    }
    return var1;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SimpleVariable basicGetVar1()
  {
    return var1;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVar1(SimpleVariable newVar1)
  {
    SimpleVariable oldVar1 = var1;
    var1 = newVar1;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.INDEX__VAR1, oldVar1, var1));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getParam2()
  {
    return param2;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParam2(int newParam2)
  {
    int oldParam2 = param2;
    param2 = newParam2;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.INDEX__PARAM2, oldParam2, param2));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SimpleVariable getVar2()
  {
    if (var2 != null && var2.eIsProxy())
    {
      InternalEObject oldVar2 = (InternalEObject)var2;
      var2 = (SimpleVariable)eResolveProxy(oldVar2);
      if (var2 != oldVar2)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, CRPackage.INDEX__VAR2, oldVar2, var2));
      }
    }
    return var2;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SimpleVariable basicGetVar2()
  {
    return var2;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVar2(SimpleVariable newVar2)
  {
    SimpleVariable oldVar2 = var2;
    var2 = newVar2;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.INDEX__VAR2, oldVar2, var2));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.INDEX__PARAM1:
        return getParam1();
      case CRPackage.INDEX__VAR1:
        if (resolve) return getVar1();
        return basicGetVar1();
      case CRPackage.INDEX__PARAM2:
        return getParam2();
      case CRPackage.INDEX__VAR2:
        if (resolve) return getVar2();
        return basicGetVar2();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.INDEX__PARAM1:
        setParam1((Integer)newValue);
        return;
      case CRPackage.INDEX__VAR1:
        setVar1((SimpleVariable)newValue);
        return;
      case CRPackage.INDEX__PARAM2:
        setParam2((Integer)newValue);
        return;
      case CRPackage.INDEX__VAR2:
        setVar2((SimpleVariable)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.INDEX__PARAM1:
        setParam1(PARAM1_EDEFAULT);
        return;
      case CRPackage.INDEX__VAR1:
        setVar1((SimpleVariable)null);
        return;
      case CRPackage.INDEX__PARAM2:
        setParam2(PARAM2_EDEFAULT);
        return;
      case CRPackage.INDEX__VAR2:
        setVar2((SimpleVariable)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.INDEX__PARAM1:
        return param1 != PARAM1_EDEFAULT;
      case CRPackage.INDEX__VAR1:
        return var1 != null;
      case CRPackage.INDEX__PARAM2:
        return param2 != PARAM2_EDEFAULT;
      case CRPackage.INDEX__VAR2:
        return var2 != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (param1: ");
    result.append(param1);
    result.append(", param2: ");
    result.append(param2);
    result.append(')');
    return result.toString();
  }

} //IndexImpl
